package team.archai.nexus.boot.platform.modules.system.vo;

import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import team.archai.nexus.boot.platform.basics.vo.BasicsTreeVO;

import java.util.ArrayList;
import java.util.List;

/**
 * @description: menu树
 * @author: lishibin
 * @create: 2020-09-19 21:56
 **/
@Getter
@Setter
@Schema(description = "菜单树形对象")
public class RouterMenuTree extends BasicsTreeVO<RouterMenuTree> {
    /**
     * 主键ID
     */
    @JsonSerialize(using = ToStringSerializer.class)
    private Long id;

    /**
     * 父节点ID
     */
    @JsonSerialize(using = ToStringSerializer.class)
    private Long parentId;

    /**
     * 子孙节点
     */
    @JsonInclude(JsonInclude.Include.NON_EMPTY)
    private List<RouterMenuTree> children;

    /**
     * 是否有子孙节点
     */
    @JsonInclude(JsonInclude.Include.NON_EMPTY)
    private Boolean hasChildren;

    @Override
    public List<RouterMenuTree> getChildren() {
        if (this.children == null) {
            this.children = new ArrayList<>();
        }
        return this.children;
    }

    /**
     * 菜单名称
     */
    private String name;

    /**
     * 菜单路径
     */
    private String path;

    /**
     * 组件路径
     */
    private String component;

    /**
     * redirect 路径
     */
    private String redirect;

    /**
     * 菜单类型
     */
    private Integer category;

    @Getter
    @Setter
    @ToString
    public static class Meta {

        private String title;

        private String icon;

        private String code;

        private String link;

        private Boolean hideInMenu;
        private Boolean hideChildrenInMenu;
        private Boolean hideInBreadcrumb;
        private Boolean hideInTab;
        private Boolean affixTab;
        private Boolean keepAlive;
        private String modalType;
        @Schema(description = "内嵌模式下第三方地址")
        private String iframeSrc;

    }

    private Meta meta;
}
